﻿namespace NetFx.SMIL.References
{
  using System;
  using System.Text;
  using System.Collections;
  using System.Collections.Generic;

  using System.Reflection;
  using System.Reflection.Emit;
  using System.Runtime.InteropServices;

  using System.Diagnostics;
  using System.Diagnostics.CodeAnalysis;
  using System.Diagnostics.SymbolStore;
  using System.Security;
  using System.Security.Permissions;

  using NetFx.MSIL;

  /// <summary>
  /// 对程序集的引用。
  /// </summary>
  public class AssemblyRef:ReflectRef
  {
    #region Statics
    public new static AssemblyRef it()
    {
      return new AssemblyRef();
    }
    public static AssemblyRef of(Assembly assembly)
    {
      return new AssemblyRef(assembly);
    }
    public static AssemblyRef of(string identifier)
    {
      return new AssemblyRef(identifier);
    }
    #endregion
    #region Properties
    /// <summary>
    /// 获取引用类型（为程序集）。
    /// </summary>
    public override DefType ReflectionType
    {
      get { return DefType.Assembly; }
    }
    /// <summary>
    /// 获取反射信息。
    /// </summary>
    public virtual Assembly ReflectInfo
    {
      get
      {
        return this.referenced as Assembly;
      }
    }
    public override bool HasReflectInfo
    {
      get
      {
        return this.ReflectInfo != null;
      }
    }
    #endregion
    #region Constructors
    public AssemblyRef() : base(null) { }
    public AssemblyRef(string identifier) : base(identifier) { }
    public AssemblyRef(Assembly assembly):this()
    {
      if (assembly != null)
      {
        this.identifier = assembly.FullName;
        this.OnBinding(assembly);
      }
    }
    #endregion
    #region Methods
    protected override ReflectRef OnBinding(object source)
    {
      return base.OnBinding(source as Assembly);
    }
    #endregion
  }
}
